import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/materialMaintenance',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/materialMaintenance/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/materialMaintenance',
    method: 'put',
    data
  })
}

// 下载 Excel 模板
export function downloadFileAPI(data) {
  return request({
    url: 'api/materialMaintenance/downloadTemplate',
    method: 'get',
    responseType: 'blob',
    data
  })
}

// 容器模板下载
export function containerDownloadFileAPI(data) {
  return request({
    url: 'api/materialMaintenance/downloadContainerTemplate',
    method: 'get',
    responseType: 'blob',
    data
  })
}

// 上传 Excel 模板
export function uploadFileAPI(data) {
  return request({
    url: 'api/materialMaintenance/importExcel',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function uploadContainerFileAPI(data) {
  return request({
    url: 'api/materialMaintenance/importContainerExcel',
    method: 'post',
    data
  })
}

// 审核
export function judgeAPI(params) {
  return request({
    url: 'api/materialMaintenance/materialMaintenance/audit',
    method: 'get',
    params
  })
}

// 批量审核
export function moreJudgeAPI(data) {
  return request({
    url: 'api/materialMaintenance/materialMaintenance/auditBatch',
    method: 'post',
    data
  })
}

export default { add, edit, del, downloadFileAPI, uploadFileAPI, containerDownloadFileAPI }
